﻿<s:SurfaceWindow x:Class="ENMAX_ArcGIS.SurfaceWindow1"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:s="http://schemas.microsoft.com/surface/2008"
                 xmlns:src="clr-namespace:ENMAX_ArcGIS"
                 xmlns:esriGeometry="clr-namespace:ESRI.ArcGIS.Client.Geometry;assembly=ESRI.ArcGIS.Client"
                 xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client"
                 xmlns:esriSymbols="clr-namespace:ESRI.ArcGIS.Client.Symbols;assembly=ESRI.ArcGIS.Client"
                 xmlns:esriConverters="clr-namespace:ESRI.ArcGIS.Client.ValueConverters;assembly=ESRI.ArcGIS.Client"
                 Title="ENMAX_ArcGIS">
    
    <s:SurfaceWindow.Resources>
            
        <XmlDataProvider x:Key="List1" XPath="Root">
            <x:XData>
                <Root xmlns="">
                    <Entry Name="Brentwood"       Image="\Resources\MapImages\Brentwood.jpg" />
                    <Entry Name="Banff Trail"     Image="\Resources\MapImages\BanffTrail.jpg" />
                    <Entry Name="University"      Image="\Resources\MapImages\University.jpg" />
                    <Entry Name="Dalhousie"       Image="\Resources\MapImages\Dalhousie.jpg" />
                    <Entry Name="Calgary"         Image="\Resources\MapImages\Calgary.jpg" />
                    <Entry Name="Saskatoon"       Image="\Resources\MapImages\Saskatoon.jpg" />
                    <Entry Name="Edmonton"        Image="\Resources\MapImages\Edmonton.jpg" />
                    <Entry Name="Winnipeg"        Image="\Resources\MapImages\Winnipeg.jpg" />
                </Root>
            </x:XData>
        </XmlDataProvider>

        <!-- Brush for ListBox -->
        <LinearGradientBrush x:Key="MyListBoxBackgroundBrush" EndPoint="1,0" StartPoint="0,0">
            <GradientStop Color="#FFA4B4BD" Offset="0"/>
            <GradientStop Color="#FFDFE9EE" Offset="1"/>
        </LinearGradientBrush>

        <!-- Brush for ListBoxItem border -->
        <LinearGradientBrush x:Key="MyListBoxItemBorderBrush" EndPoint="0.5,0" StartPoint="0.5,1">
            <GradientStop Color="#19000000" Offset="0.269"/>
            <GradientStop Color="#00000000" Offset="1"/>
        </LinearGradientBrush>
        
        <!-- Image Brush for the scatterview layer -->
        <ImageBrush x:Key="MapOverlay" Stretch="Fill" Opacity="0.25" ImageSource="Resources/bgmap.png"/>
        <ImageBrush x:Key="ElectricityOverlay" Stretch="Fill" Opacity="0.5" ImageSource="Resources/Electricity.png"/>
        
        <!-- Style for corner function menus -->
        <Style x:Key="FunctionMenuOutline" TargetType="{x:Type Path}">
            <Setter Property="Opacity" Value="1" />
            <Setter Property="Stretch" Value="Fill" />
            <Setter Property="Fill" Value="Yellow" />
            <Setter Property="Stroke" Value="{x:Null}" />
        </Style>
        
        <!-- Style for ListBoxItems -->
        <Style TargetType="{x:Type s:SurfaceListBoxItem}">
            <Setter Property="BorderThickness" Value="1,0,0,0"/>
            <Setter Property="BorderBrush" Value="{StaticResource MyListBoxItemBorderBrush}"/>
            <!-- selection brush is set through the SystemColors.HighlightBrushKey in MyListBoxStyle -->
        </Style>

        <Style x:Key="MyListStyle" TargetType="{x:Type s:SurfaceListBox }">
            <Style.Resources>
                <!-- Brush for selected ListBoxItems -->
                <LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" EndPoint="0.5,0" StartPoint="0.5,1">
                    <GradientStop Color="#33000000" Offset="0"/>
                    <GradientStop Color="#00000000" Offset="1"/>
                </LinearGradientBrush>
            </Style.Resources>

            <Setter Property="Background" Value="{StaticResource MyListBoxBackgroundBrush}"/>
            <Setter Property="Padding" Value="5"/>
            <Setter Property="SelectionMode" Value="Single"/>

            <Setter Property="Height" Value="135"/>
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <StackPanel Margin="5" RenderTransformOrigin="0.5, 0.5">
                            <Image Source="{Binding XPath=@Image}" Height="100" Width="100" />
                            <TextBlock Text="{Binding XPath=@Name}" Foreground="Black" HorizontalAlignment="Center"/>
                        </StackPanel>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border CornerRadius="50,50,0,0" BorderBrush="Black" BorderThickness="1"  Height="300" >
                            <s:SurfaceScrollViewer Background="{TemplateBinding Background}"
                                                 VerticalScrollBarVisibility="Disabled"
                                                 HorizontalScrollBarVisibility="Hidden"
                                                 CanContentScroll="true">
                                <src:LoopingPanel IsItemsHost="True"/>
                            </s:SurfaceScrollViewer>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- Style for Pods -->
        <Style x:Key="PodStyle" TargetType="{x:Type s:ScatterViewItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Grid Background="Transparent">
                            <ContentPresenter Content="{TemplateBinding Property=ContentControl.Content}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <!-- Style for a cursor content -->
        <Style x:Key="MyCursorStyle" TargetType="{x:Type ContentControl }">
            <Setter Property="Background" Value="{Binding XPath=@Background}"/>
            <Setter Property="Height" Value="160"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Image Source="{Binding XPath=@Image}" VerticalAlignment="Stretch" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!--Round Button corner buttons to activate the corner tray buttons -->
        <Style x:Key="RoundButton" TargetType="{x:Type s:SurfaceButton}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type s:SurfaceButton}">
                        <Grid>
                            <Ellipse Stroke="{TemplateBinding Property=BorderBrush}" 
                                     StrokeThickness="{TemplateBinding Property=BorderThickness}" 
                                     Fill="{StaticResource ElectricityOverlay}" 
                                     Margin="40,40,0,0" Width="270" Height="270"/>
                            <Ellipse Stroke="{TemplateBinding Property=Foreground}"  
                                     StrokeThickness="2" Margin="43,43,0,0"  Width="270" Height="270"/>
                            <ContentPresenter HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="179" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <!-- Activated Round Button corner trays to hold function buttons -->
        <Style x:Key="Functions" TargetType="{x:Type s:SurfaceButton}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type s:SurfaceButton}">
                        <Grid>
                            <Ellipse Stroke="{TemplateBinding Property=BorderBrush}" StrokeThickness="{TemplateBinding Property=BorderThickness}" Fill="{TemplateBinding Property=Background}" Margin="0,0,0,0" Width="270" Height="270"/>
                            <Ellipse Stroke="{TemplateBinding Property=Foreground}"  StrokeThickness="2" Margin="2,2,0,0"  Width="270" Height="270"/>
                            <ContentPresenter HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="179" />
                            <!-- The grid template to hold the buttons -->
                            <Grid Width="100" Height="100">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="33"/>
                                    <RowDefinition Height="33" />
                                    <RowDefinition Height="33"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="33"/>
                                    <ColumnDefinition Width="33" />
                                    <ColumnDefinition Width="33"/>
                                </Grid.ColumnDefinitions>

                                <!--<Path Stroke="Blue" Fill="Pink" Opacity="0.5">
                                    <Path.Data>
                                        <PathGeometry>
                                            <PathGeometry.Figures>
                                                <PathFigureCollection>
                                                    <PathFigure IsClosed="True" StartPoint="0,135">
                                                        <PathFigure.Segments>
                                                            <PathSegmentCollection>

                                                                <ArcSegment Size="50,1" RotationAngle="0" IsLargeArc="False" SweepDirection="Clockwise" Point="25,55" />



                                                                <LineSegment Point="45,79" />
                                                                <LineSegment Point="45,135" />
                                                            </PathSegmentCollection>
                                                        </PathFigure.Segments>
                                                    </PathFigure>
                                                </PathFigureCollection>
                                            </PathGeometry.Figures>
                                        </PathGeometry>-->

                                        <!--<GeometryGroup FillRule="EvenOdd">

                                            <EllipseGeometry RadiusX="100" RadiusY="100" Center="135,135" />
                                            <EllipseGeometry RadiusX="135" RadiusY="135" Center="135,135" />
                                            <LineGeometry StartPoint="135,135" EndPoint="25,35" />
                                            <LineGeometry StartPoint="135,135" EndPoint="30,10" />
                                            <LineGeometry StartPoint="135,135" EndPoint="25,35" />
                                        </GeometryGroup>-->
                                    <!--</Path.Data>
                                </Path>-->

                                <s:SurfaceButton  x:Name="ExitButton" Content="Exit" FontStyle="Normal" FontSize="12" Foreground="White" Grid.Column="2" Grid.Row="0" Background="Red" ContactTapGesture="ExitButton_ContactTapGesture"
                                              Style="{StaticResource {ComponentResourceKey ResourceId=AccessButton, TypeInTargetAssembly={x:Type s:SurfaceButton}}}"/>
                                
                                <s:SurfaceButton Content="List" FontStyle="Normal" FontSize="12" Foreground="White" Grid.Column="1" Grid.Row="1" x:Name="ListButton" Background="Green" ContactTapGesture="ListButton_ContactTapGesture"
                                                 Style="{StaticResource {ComponentResourceKey ResourceId=AccessButton, TypeInTargetAssembly={x:Type s:SurfaceButton}}}">
                                    
                                </s:SurfaceButton>
                                <s:SurfaceButton Content="Config" FontStyle="Normal" FontSize="12" Foreground="White" Grid.Column="0" Grid.Row="2" x:Name="SearchButton" Background="Blue" ContactTapGesture="SearchButton_Click"
                                                 Style="{StaticResource {ComponentResourceKey ResourceId=AccessButton, TypeInTargetAssembly={x:Type s:SurfaceButton}}}">
                                   
                                </s:SurfaceButton>
                            </Grid>
                            
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <!-- The exit function button -->
        <Style x:Key="ExitButton" TargetType="{x:Type s:SurfaceButton}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type s:SurfaceButton}">
                        <Grid>
                            <s:SurfaceButton  x:Name="Exit" Grid.Column="{TemplateBinding Property=Grid.Column}" Grid.Row="{TemplateBinding Property=Grid.Row}" Background="Red"
                                              Style="{StaticResource {ComponentResourceKey ResourceId=AccessButton, TypeInTargetAssembly={x:Type s:SurfaceButton}}}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="ExitConfirmDialog" TargetType="{x:Type s:ScatterViewItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type s:ScatterViewItem}">
                        <Grid>
                            <s:ScatterViewItem Background="Black" Width="100" Height="100">
                                <StackPanel Orientation="Vertical">
                                    <s:SurfaceButton Name="ConfirmExitButton" Margin="2" Height="44" Content="Confirm Exit" Background="IndianRed" Click="ConfirmExitButton_Click"/>
                                    <s:SurfaceButton Name="CancelExitButton" Margin="2"  Height="44"  Content="Cancel Exit" Background="Gray" Click="CancelExitButton_Click"/>
                                </StackPanel>
                            </s:ScatterViewItem>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </s:SurfaceWindow.Resources>


    <Grid Background="{StaticResource MapOverlay}" >
        <Grid.RowDefinitions>
            <RowDefinition Height="135"/>
            <RowDefinition Height="754" />
            <RowDefinition Height="135"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="135"/>
            <ColumnDefinition Width="498" />
            <ColumnDefinition Width="135"/>
        </Grid.ColumnDefinitions>
        <Grid.LayoutTransform>
            <RotateTransform x:Name="OrientationTransform" Angle="90">
                
            </RotateTransform>
        </Grid.LayoutTransform>
            <!-- Main Scatter View area, allowing users to bring up multiple selected maps to this area to be 
             manipulated -->
        <!-- OLD DRAG AND DROP SCATTER VIEW 
        <src:DragDropScatterView x:Name="ScatterLayer" AllowDrop="True" Background="Transparent" Grid.Column="1" Grid.Row="1" />
        -->
        
        <!-- NEW Scatter view, adding MapFrame by two-point gestures -->
        

        <!-- Background map for users to select areas for more detail -->
        <src:ArcGisMap x:Name="BackgroundMap" Grid.Column="0" Grid.ColumnSpan="3" Grid.RowSpan="3">
            
        </src:ArcGisMap>

        <src:TroublePinLayer x:Name="troublePinLayer" Background="{StaticResource MapOverlay}" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3" 
                             ContactDown="BackgroundMapContactDown" ContactUp="BackgroundMapContactUp"/>

        <src:TwoPointScatterView x:Name="scatterLayer" Grid.Column="0" Grid.Row="0" Grid.RowSpan="3" Grid.ColumnSpan="3" />
            
       
        

        <!-- Corner function menu button for lower left hand side -->
        <s:SurfaceButton Grid.Row="2" Grid.Column="2"
                         Name="ButtonBottomLeft" Click="ButtonBottomLeft_Click"  
                         Style="{DynamicResource RoundButton}" Background="White"
                         BorderBrush="AliceBlue" BorderThickness="4" Foreground="AliceBlue" />
        <s:SurfaceButton Grid.Row="2" Grid.Column="2" Background="LightYellow" Visibility="Hidden"
                         Name="FunctionMenuBottomLeft" Click="FunctionMenuBottomLeft_Click"
                         Style="{DynamicResource Functions}" BorderBrush="AliceBlue" 
                         BorderThickness="4" Foreground="AliceBlue">
        </s:SurfaceButton>
        <!-- Exit Confirmation Dialog box for lower left corner -->
        <s:ScatterViewItem Name="ExitConfirmDialogBottomLeft" Style="{DynamicResource ExitConfirmDialog}"  Grid.Column="1" Grid.Row="1"
                           HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="Hidden" Orientation="0" >
            
        </s:ScatterViewItem>



        <!-- Corner function menu button for upper right hand side -->
        <s:SurfaceButton Grid.Row="0" Grid.Column="0"
                         Name="ButtonUpperRight" Click="ButtonUpperRight_Click"  
                         Style="{DynamicResource RoundButton}" Background="White"
                         BorderBrush="AliceBlue" BorderThickness="4" Foreground="AliceBlue">
            <s:SurfaceButton.RenderTransform>
                <TransformGroup>
                    <RotateTransform   Angle="180"></RotateTransform>
                    <TranslateTransform  X="135" Y="135" ></TranslateTransform>
                </TransformGroup>
            </s:SurfaceButton.RenderTransform>
        </s:SurfaceButton>
        <s:SurfaceButton Grid.Row="0" Grid.Column="0" Background="LightYellow" Visibility="Hidden"
                         Name="FunctionMenuUpperRight" Click="FunctionMenuUpperRight_Click"
                         Style="{DynamicResource Functions}" BorderBrush="AliceBlue" 
                         BorderThickness="4" Foreground="AliceBlue" >
            <s:SurfaceButton.RenderTransform>
                <TransformGroup>
                    <RotateTransform   Angle="180"></RotateTransform>
                    <TranslateTransform  X="135" Y="135" ></TranslateTransform>
                </TransformGroup>
            </s:SurfaceButton.RenderTransform>
        </s:SurfaceButton>
        <!-- Exit Confirmation Dialog box for upper right corner -->
        <s:ScatterViewItem Name="ExitConfirmDialogUpperRight" Style="{DynamicResource ExitConfirmDialog}"  Grid.Column="1" Grid.Row="1"
                           HorizontalAlignment="Left" VerticalAlignment="Top" Visibility="Hidden">
            
        </s:ScatterViewItem>

        <!-- Corner function menu button for upper left hand side -->
        <s:SurfaceButton Grid.Row="2" Grid.Column="0"
                         Name="ButtonUpperLeft" Click="ButtonUpperLeft_Click"   
                         Style="{DynamicResource RoundButton}" Background="White"
                         BorderBrush="AliceBlue" BorderThickness="4" Foreground="AliceBlue">       
            <s:SurfaceButton.RenderTransform>
                <TransformGroup>
                    <RotateTransform   Angle="90"></RotateTransform>
                    <TranslateTransform X="135"  ></TranslateTransform>
                </TransformGroup>
            </s:SurfaceButton.RenderTransform>
        </s:SurfaceButton>
        <s:SurfaceButton Grid.Row="2" Grid.Column="0" Background="LightYellow" Visibility="Hidden"
                         Name="FunctionMenuUpperLeft" Click="FunctionMenuUpperLeft_Click"
                         Style="{DynamicResource Functions}" BorderBrush="AliceBlue" 
                         BorderThickness="4" Foreground="AliceBlue" >
            <s:SurfaceButton.RenderTransform>
                <TransformGroup>
                    <RotateTransform   Angle="90"></RotateTransform>
                    <TranslateTransform X="135"  ></TranslateTransform>
                </TransformGroup>
            </s:SurfaceButton.RenderTransform>
        </s:SurfaceButton>
        <!-- Exit Confirmation Dialog box for upper left corner -->
        <s:ScatterViewItem Name="ExitConfirmDialogUpperLeft" Style="{DynamicResource ExitConfirmDialog}"  Grid.Column="1" Grid.Row="1"
                           HorizontalAlignment="Left" VerticalAlignment="Bottom" Visibility="Hidden">
        </s:ScatterViewItem>
        

        <!-- Corner function menu button for lower right hand side -->
        <s:SurfaceButton Grid.Row="0" Grid.Column="2"
                         Name="ButtonBottomRight" Click="ButtonBottomRight_Click"     
                         Style="{DynamicResource RoundButton}" Background="White"
                         BorderBrush="AliceBlue" BorderThickness="4" Foreground="AliceBlue">
           <!-- <Image Source="Resources\Buttons\Exit.png" Stretch="Fill" Height="90" Width="90" /> -->
            <s:SurfaceButton.RenderTransform>
                <TransformGroup>
                    <RotateTransform   Angle="-90"></RotateTransform>
                    <TranslateTransform  Y="135" ></TranslateTransform>
                </TransformGroup>
            </s:SurfaceButton.RenderTransform>
        </s:SurfaceButton>
        <s:SurfaceButton Grid.Row="0" Grid.Column="2" Background="LightYellow" Visibility="Hidden"
                         Name="FunctionMenuBottomRight" Click="FunctionMenuBottomRight_Click"
                         Style="{DynamicResource Functions}" BorderBrush="AliceBlue" 
                         BorderThickness="4" Foreground="AliceBlue" >
           <s:SurfaceButton.RenderTransform>
                <TransformGroup>
                    <RotateTransform   Angle="-90"></RotateTransform>
                    <TranslateTransform  Y="135" ></TranslateTransform>
                </TransformGroup>
            </s:SurfaceButton.RenderTransform>
        </s:SurfaceButton>
        <!-- Exit Confirmation Dialog box for lower right corner -->
        <s:ScatterViewItem Name="ExitConfirmDialogBottomRight" Style="{DynamicResource ExitConfirmDialog}"  Grid.Column="1" Grid.Row="1"
                           HorizontalAlignment="Right" VerticalAlignment="Top" Visibility="Hidden">
            
        </s:ScatterViewItem>
        
        
    </Grid>
</s:SurfaceWindow>
